package com.shangguan.springboot.controller;

import com.google.gson.Gson;
import com.shangguan.springboot.dao.TUserMapper;
import com.shangguan.springboot.entity.TUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName: MemberController
 * @Description:
 * @Author: 一尘
 * @Date: 2020 年 03 月 10 12:32
 * @Version 1.0
 */
@Controller
@RequestMapping("/member")
@Slf4j
public class MemberController {
    @Autowired
    TUserMapper  tUserMapper;

    @GetMapping("/member-list")
    public  String memberList(){
       log.info("--------------member-list------------");
        return "member-list";
    }
    @GetMapping("/member-list1")
    public  String memberList1(){
        log.info("--------------member-list1------------");
        return "member-list1";
    }

    @GetMapping("/member-edit")
    public  String memberEdit(){
        log.info("--------------member-edit------------");
        return "member-edit";
    }
    @GetMapping("/member-query")
     @ResponseBody
    public  Object memberQuery(){
        log.info("--------------member-query------------");
        List<TUser> tUsers = tUserMapper.selectAll();
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("code",0);
        map.put("msg","success");
        map.put("count",tUsers.size());
        map.put("data",tUsers);
        Gson  gson = new Gson();
        return gson.toJson(map);
    }
}
